import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn } from 'typeorm';
import { ApiProperty } from '@nestjs/swagger';

@Entity('sys_user',{ database: "daijia_system" }) // 数据库表名
export class SystemUserEntity {
  @ApiProperty({ description: '用户ID', example: 1 })
  @PrimaryGeneratedColumn({ type: 'bigint', name: 'id', unsigned: true })
  id: number;

  @ApiProperty({ description: '用户名', example: 'testuser' })
  @Column({ type: 'varchar', length: 20, unique: true, nullable: false, comment: '用户名' })
  username: string;

  @ApiProperty({ description: '密码', example: 'password123' })
  @Column({ type: 'varchar', length: 32, nullable: false, comment: '密码' })
  password: string;

  @ApiProperty({ description: '姓名', example: '张三', required: false })
  @Column({ type: 'varchar', length: 50, nullable: true, comment: '姓名' })
  name: string;

  @ApiProperty({ description: '电话号码', example: '12345678901', required: false })
  @Column({ type: 'varchar', length: 11, nullable: true, comment: '电话号码' })
  phone: string;

  @ApiProperty({ description: '描述', example: '这是一个测试用户', required: false })
  @Column({ type: 'varchar', length: 255, nullable: true, comment: '描述' })
  description: string;

  @ApiProperty({ description: '状态：0-禁用，1-启用', example: 1, required: false })
  @Column({ type: 'tinyint', nullable: true, comment: '状态：0-禁用，1-启用' })
  status: number;

  @ApiProperty({ description: '头像URL', example: 'http://example.com/avatar.jpg', required: false })
  @Column({ type: 'varchar', length: 200, nullable: true, comment: '头像URL' })
  headUrl: string;

  @ApiProperty({ description: '部门ID', example: 1, required: false })
  @Column({ type: 'bigint', nullable: true, comment: '部门ID' })
  deptId: number;

  @ApiProperty({ description: '岗位ID', example: 2, required: false })
  @Column({ type: 'bigint', nullable: true, comment: '岗位ID' })
  postId: number;

  @ApiProperty({ description: '是否删除：0-未删除，1-已删除', example: 0 })
  @Column({ type: 'tinyint', nullable: false, default: 0, comment: '是否删除：0-未删除，1-已删除' })
  isDeleted: number;

  @ApiProperty({ description: '创建时间', example: '2023-01-01T00:00:00.000Z' })
  @CreateDateColumn({
    type: 'timestamp',
    precision: 6,
    comment: '创建时间',
  })
  createTime: Date;

  @ApiProperty({ description: '更新时间', example: '2023-01-01T00:00:00.000Z' })
  @UpdateDateColumn({
    type: 'timestamp',
    precision: 6,
    comment: '更新时间',
  })
  updateTime: Date;
}